# -*- coding: utf-8 -*-
import cv2
from fastapi import APIRouter, Depends, Request, Response, UploadFile
from fastapi.security import OAuth2PasswordRequestForm
from loguru import logger

from sio import sio 

from app.api import jwt
from app.utils.generate_string import get_cur_timestamp
from rasip.camera import get_rasip_photo
from sio_agv.agv_socket import AGV
from app.core.conf import ST
from app.models.user import User
from app.schemas.agv import RQAGV
from app.common.exception.agv import AGVError
from app.common.response.response_schema import response_base
from app.api.service import agv_service


rasip_router = APIRouter()


@rasip_router.get('/photo', summary='take photo')
async def take_photo():
    img = get_rasip_photo(ST.SHORT_CAMERA_URL)
    timestamp = get_cur_timestamp()
    cv2.imwrite(f"{ST.IMG_DRAW_PATH}\{str(timestamp)}_hand.jpg",img)
    await sio.emit("cv_add", f'http://10.12.48.223:7000/img/{timestamp}_hand.jpg', room="agv")
    return response_base.response_200(msg='执行成功',data='')


